// https://leetcode.cn/problems/longest-continuous-increasing-subsequence/description/

// 算法思路总结：
// 1. 使用动态维护序列法求解最长连续递增子序列
// 2. 遇到递增元素扩展序列，遇到非递增元素重置序列
// 3. 实时更新最大序列长度记录
// 4. 时间复杂度：O(n)，空间复杂度：O(n)

#include <iostream>
using namespace std;

#include <vector>
#include <algorithm>

class Solution 
{
public:
    int findLengthOfLCIS(vector<int>& nums) 
    {
        int m = nums.size();
        int ret = 0;
        vector<int> subV;

        for (int i = 0 ; i < m ; i++)
        {
            if (subV.empty() || nums[i] > subV.back())
            {
                subV.push_back(nums[i]);
                ret = max(ret, (int)subV.size());
            }
            else
            {
                subV.clear();
                subV.push_back(nums[i]);
            }
        }

        return ret;
    }
};

int main()
{
    vector<int> v1 = {1,3,5,4,7}, v2 = {2,2,2,2,2};
    Solution sol;

    cout << sol.findLengthOfLCIS(v1) << endl;
    cout << sol.findLengthOfLCIS(v2) << endl;

    return 0;
}